﻿CREATE PROCEDURE [acms].[SiteVersion_GetCurrentBySiteUrl]
	@SiteUrl varchar(255)
AS
	declare @SiteId int
	
	select @SiteId = Id From Site_View where Root = @SiteUrl
	
	if(@SiteId is null)
		select @SiteId = SiteId From SiteMappings where MappingName = @SiteUrl

	SELECT top 1 *
	From SiteVersion_View
	Where SiteId = @SiteId
		and Change <= getutcdate()
	order by change desc
RETURN 0